//
//  FKLogisticsCell.m
//  BaiYeMallShop
//
//  Created by Macbook Pro on 2018/11/17.
//  Copyright © 2018 Macbook Pro. All rights reserved.
//

#import "FKLogisticsCell.h"

@interface FKLogisticsCell ()

@property (nonatomic, weak) UIImageView *iconView;
@property (nonatomic, weak) UILabel *contentLabel;
@property (nonatomic, weak) UILabel *timeLabel;

@end

@implementation FKLogisticsCell

- (void)setupSubviews
{
    [super setupSubviews];
    
    UIImageView *iconView = [[UIImageView alloc] init];
    [self.contentView addSubview:iconView];
    self.iconView = iconView;
    iconView.contentMode = UIViewContentModeScaleToFill;
    
    UILabel *contentLabel = [UILabel fk_labelWithFont:fk_adjustFont(13) textColor:fkColor333333];
    [self.contentView addSubview:contentLabel];
    self.contentLabel = contentLabel;
    contentLabel.numberOfLines = 3;
    
    UILabel *timeLabel = [UILabel fk_labelWithFont:fk_adjustFont(13) textColor:fkColor333333];
    [self.contentView addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(5);
        make.top.bottom.equalTo(self.contentView);
        make.width.mas_equalTo(33 / 2);
    }];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
        make.top.equalTo(self.contentView).offset(10);
    }];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(contentLabel);
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
}

- (void)setDict:(NSDictionary *)dict
{
    _dict = dict;
    
    self.contentLabel.text = dict[@"AcceptStation"];
    self.timeLabel.text = dict[@"AcceptTime"];
}

- (void)setType:(LogisticsCellType)type
{
    _type = type;
    
    switch (type) {
        case LogisticsCellTypeUp:
            self.iconView.image = [UIImage imageNamed:@"trade_up"];
            break;
        case LogisticsCellTypeNormal:
            self.iconView.image = [UIImage imageNamed:@"trade_normal"];
            break;
        case LogisticsCellTypeDown:
            self.iconView.image = [UIImage imageNamed:@"trade_down"];
            break;
        default:
            break;
    }
}

@end
